with_horizontal_rule {
width: 100%;
text-align: center; /* Remove this to align left */
border-bottom: 1px solid #000;
line-height: 0.1em;
margin: 10px 0 20px;
}
p span {
background:#fff;
padding:0 10px;
}
/* HTML */
<p class="with_horizontal_rule"><span>Your text goes here</span></p>